<?php
require('modelo_twitter.php');

if($_POST)
{
	if($_POST['tipo']=='menciones')
	{
		$results=buscar_menciones($_POST['texto']);
//		echo '<pre>'.print_r($results, true).'</pre>';
	}
	else if($_POST['tipo']=='hash')
	{
		$results=buscar_hash($_POST['texto']);
	}
	else if($_POST['tipo']=='palabra')
	{
		$results=buscar_palabra($_POST['texto']);
	}
	?>
	<form id="form" name="form" method="post" style="text-align:left;" action="javascript:formus(document.getElementById('form'),'campanas/inserta_tuit.php','mmm')">
	<input type="hidden" id="palabras" name="palabras" value="<?=$_POST['texto']?>">

	<?php
	for($a=0;$a<count($results);$a++)
	{
	?>
	<input type="hidden" id="usuario_<?=$a?>" name="usuario_<?=$a?>" value="<?=$results[$a]->from_user?>">
	<input type="hidden" id="mensaje_<?=$a?>" name="mensaje_<?=$a?>" value="<?=$results[$a]->text?>">
    <table width="70%" style="text-align:left;">
    <tr><td rowspan="3"  width="50px" align="center"></td>
    <td rowspan="3"  width="70px" align="center"></td>
    <td rowspan="3" width="40px"><img src="<?php echo $results[$a]->profile_image_url; ?>" border="0" width="40px" height="40px"></td>
	<td style="color:blue;font-family: Helvetica;font-size: 14px; font-weight:bold;"><?php echo $results[$a]->from_user;?></td></tr>
    <tr><td style="font-family: Helvetica;font-size: 13px;"><?php echo $results[$a]->text;?></td></tr>
    <tr><td style="font-family: Helvetica;font-size: 13px;"><?php echo $results[$a]->created_at;?><br><br><br></td></tr>
    </table>
<?php //$r2 = $connection->post('statuses/update', array('status'=>'@'.$r1[$a]['user']['screen_name'].' '.'probando replay'));
 }

	
}
?>
<input type='hidden' name='tuits' value='<?=$a?>' id='tuits'>


<?php

	$link=mysql_connect("localhost","root","");
	mysql_select_db("demo_inventario");
	$query="SELECT * FROM empresa";
	$consulta=mysql_query($query);
	
	$select="<div width='100%' style='text-align:center;'><select id='empresa' name='empresa'>
	<option value='0'>Selecciona</option>";
	
	while($row=mysql_fetch_array($consulta))
	{
		$select.="<option value='".$row['id_empresa']."'>".$row['nombre']."</option>";
	}
	$select.="</select>
	<br><br>
	<input type='submit' value='Agregar resultados'><br><br>
	
	</div></form>";

echo $select;

?>